package work.com.Exam01;

import java.util.Scanner;

public class CAB {
    public static boolean canMarry(Person person1,Person person2){
        if ( !person1.getGander().equals(person2.getGander())){
            if (person1.getGander() =='男' && person1.getAge() >=22
                    || person1.getGander() =='女' && person1.getAge() >=20 ){
                if (person2.getGander() =='男' && person2.getAge() >=22
                        || person2.getGander() =='女' && person2.getAge() >=20 ){
                    if (!person1.getMarry() && !person2.getMarry()){
                        return true;
                    }
                }
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入姓名：");
        String name1 = sc.next();
        System.out.println("请输入性别：");
        Character gender1 = sc.next().charAt(0);
        System.out.println("请输入年龄：");
        Integer age1 = sc.nextInt();
        System.out.println("是否结婚（是/否）");
        Boolean marry1 = sc.next().equals("是");
        Person person1 = new Person(name1,gender1,age1,marry1);
        System.out.println("请输入姓名：");
        String name2 = sc.next();
        System.out.println("请输入性别：");
        Character gender2 = sc.next().charAt(0);
        System.out.println("请输入年龄：");
        Integer age2 = sc.nextInt();
        System.out.println("是否结婚（是/否）");
        Boolean marry2 = sc.next().equals("是");
        Person person2 = new Person(name2,gender2,age2,marry2);

        if (canMarry(person1, person2)){
            System.out.println("你们可以结婚啦！");
        }else {
            System.out.println("你们的情况不符合法定结婚规范！");
        }
    }
}
